package com.chookss.tiku.util;

import com.chookss.tiku.entity.SubjectAnswer;
import com.chookss.tools.Utils;

import java.util.ArrayList;
import java.util.List;

/**
 * Company:
 * Project:
 * Author: liuhaoge
 * Date: 2020/12/29 19:36
 * Note:
 */
public class TiKuUtils {
    public static String[] abc=new String[]{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    public static String recordTypeName(String type) {
        if (type == null) {
            return "";
        }
//        智能推荐1专项2模拟3
        switch (type) {
            case "1": return "智能题库";
            case "2": return "专项练习";
            case "3": return "模拟卷";
            case "4": return "正式考试";
            default: return type;
        }
    }

    public static String subjectTypeName(String subjectTypeCode) {
        if (subjectTypeCode == null) {
            return "";
        }
        switch (subjectTypeCode) {
            case "1001": return "单选题";
            case "1002": return "多选题";
            case "1003": return "判断题";
            case "1004": return "填空题";
            case "1005": return "问答题";
            default: return subjectTypeCode;
        }
    }
    public static String errorAnswer(String errorProneOption) {
        if (Utils.isNull(errorProneOption)) {
            return "";
        }
        String errors="";
       String[] datas=errorProneOption.split(",");
        for (int i = 0; i < datas.length; i++) {
            if(i==0){
                errors=errors+abc[Utils.changeNumber(datas[i])-1];
            }else{
                errors=errors+","+abc[Utils.changeNumber(datas[i])-1];
            }
        }
        return errors;
    }
    public static String subjectTypeName2(String subjectTypeCode) {
        if (Utils.isNull(subjectTypeCode)) {
            return "单";
        }
        switch (subjectTypeCode) {
            case "1001": return "单";
            case "1002": return "多";
            case "1003": return "判";
            case "1004": return "填";
            case "1005": return "答";
            default: return subjectTypeCode;
        }
    }
    public static String subjecMemoryLv(String memoryLvl) {
        if (Utils.isNull(memoryLvl)) {
            return "未记忆";
        }
        switch (memoryLvl) {
            case "01": return "未记忆";
            case "02": return "开始记忆";
            case "03": return "正在巩固";
            case "04": return "已牢记";
            case "05": return "开始遗忘";
            case "06": return "已遗忘";
            default: return memoryLvl;
        }
    }
    //获取题目的得分
    public static boolean myAnswerIsRight(List<SubjectAnswer> answers , List<String> myAnswers) {
        if (myAnswers == null || answers == null || answers.isEmpty() || myAnswers.isEmpty()) {
            return false;
        }
        List tmp = new ArrayList(myAnswers);
        int rightCount = 0;
        for (SubjectAnswer it : answers) {
            if ("1".equals(it.isRightAnswer)) {
                tmp.remove(it.lvlNo);
                rightCount++;
            }
        }
        if (myAnswers.size() != rightCount || !tmp.isEmpty()) {
            return false;
        }
        return true;
    }
}
